<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="m" uri="http://localhost:8080/cxy" %>
<%@ include file="base.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>${sessionScope.currUser.userName }--欢迎使用BluMine</title>
	<link href="${basePath }/styles/style.css" rel="stylesheet" type="text/css" />
	<link href="${basePath }/scripts/tip/tipTip.css" rel="stylesheet" type="text/css" />
	<link href="${basePath }/scripts/easy_validator/css/validate.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="${basePath}/scripts/jquery.js"></script>
	<script type="text/javascript" src="${basePath }/scripts/tip/tip.js"></script>
	<script type="text/javascript" src="${basePath }/scripts/easy_validator/js/easy_validator.js"></script>
	<script type="text/javascript" src="${basePath }/scripts/easy_validator/js/jquery.bgiframe.min.js"></script>
		<script type="text/javascript">
			$(document).ready(function(){
				$(".tip").tipTip();
			});
		</script>
</head>

<body>
	<%@ include file="header.jsp"%>
	<%@ include file="secondary-bar.jsp"%>
	<%@ include file="sidebar.jsp"%>
 <div id="main">
    <div class="column">
    	<div class="module_content">
       	  <div id="feed_box">
            <div class="form_div">
                  <form id="new_activity" class="new_activity" method="post" action="#">
                    <label>最新动态</label>
                      <textarea id="activity_data" class="activity" tip="不能为空" reg="^.+$"></textarea>
                    <input type="button" class="btn_new_activity" value="发布"/>
                  </form>
              </div>
              <c:forEach items="${messageList}" var="message">
	            <div class="activity_item">
	            	<div class="gra"><img class="nomal"src="images/issues.jpg" /></div>
	              	<m:drawImgByType type="${message.type }" />
	              	${message.content }
	                <p>Update by
		                <span class="author">${message.user.userName }</span>
		                <span class="date">${message.sendTime }</span>
	                </p>
	            </div>
            </c:forEach>
            
          </div>
			<script type="text/javascript">
				$(document).ready(function() {
					setInterval(function(){
						var v = $("#content").val();
						$.getJSON("message!ajaxList.jspx",function(json){
							$(json).each(function(){
								var str = "<div class=\"activity_item\">";
								str += "<div class=\"gra\"><img class=\"nomal\" src=\"images/issues.jpg\" /></div>";
								str += "<img width=\"16px\" height=\"16px\" src=\"${basePath }/images/task.png\" />";
								str += this.content;
								str += "<p>Update by";
								str += "<span class=\"author\">" + this.userName + "</span>";
								str += "<span class=\"date\">" + this.sendTime + "</span></p>";
								str += "</div>";
								$(str).insertBefore(".activity_item:first");
							});
						});
					},15000);
					$(".btn_new_activity").click(function(){
						var val = $("#activity_data").val();
						$.post("message!ajaxAdd.jspx",{"message.content":val},function(){
							var str = "<div class=\"activity_item\">";
								str += "<div class=\"gra\"><img class=\"nomal\" src=\"images/issues.jpg\" /></div>";
								str += "<img width=\"16px\" height=\"16px\" src=\"${basePath }/images/comments.png\" />";
								str += val;
								str += "<p>Update by";
								str += "<span class=\"author\">${sessionScope.currUser.userName}</span>";
								str += "<span class=\"date\">2011-06-24 12:12:12</span></p>";
								str += "</div>";
								$(str).insertBefore(".activity_item:first");
						});
					});
				});
			</script>
        <div class="my_activity">
      	<h3 class="mytask">其他人正在...</h3>
      	<c:forEach items="${issuesList}" var = "i">
      		<c:if test="${i.workUser.id  ne sessionScope.currUser.id}">
		      	<div class="issue_item">
		      		<span class="tiptip"><m:drawImg state="${i.state}"/></span>
	                <a href="issues!get.jspx?issues.id=${i.workUser.id}">${i.content}</a>
	                <span class="date">${i.createTime}</span>
		        </div>
	        </c:if>
        </c:forEach>
      </div>
      <div class="my_activity">
      	<h3 class="mytask">分配给我的任务</h3>
      	<c:forEach items="${issuesList}" var = "i">
      		<c:if test="${i.workUser.id  eq sessionScope.currUser.id}">
		      	<div class="issue_item">
		      			<span class="tiptip"><m:drawImg state="${i.state}"/></span>
		                <a href="issues!get.jspx?issues.id=${i.workUser.id}">${i.content}</a>
		                <span class="date">${i.createTime}</span>
		        </div>
	        </c:if>
        </c:forEach>
      </div>
        <div>
      </div>
     </div>
    </div>
   </div>
</body>
</html>
